Skip to content

Support full constraint syntax of library.properties depends field #384

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
May 26, 2022
Merged

Support full constraint syntax of library.properties depends field #384

merged 5 commits into from
May 26, 2022

Conversation

per1234
Copy link
Contributor

@per1234 per1234 commented May 26, 2022

Arduino CLI and the Library Manager system have support for specifying library dependency version constraints in the depends field of the library.properties metadata file.

This was previously validated as part of the general depends field data format check in rule LP047.

The constraint system has recently been made much more capable through the addition of support for more syntax.

The previous approach for validating the version constraint was a complex and lengthy regular expression in the library.properties JSON schema. Extending this to comprehensively validate the full range of constraint forms possible with the new syntax will not be feasible or maintainable.

The new approach is to validate it using the same go.bug.st/relaxed-semver module used by Arduino CLI and arduino/libraries-repository-engine to check the version constraint syntax in this field.

The JSON schema based LP047 is now used solely for validating the data format of the depends field. A new rule LP058 is dedicated to checking the version constraint syntax within each of the field items.

per1234 added 4 commits May 25, 2022 22:12
At the time the dependency on `go.bug.st/relaxed-semver` was added to the project, there was not a release version
available, so it was necessary to use a "pseudo-version" instead.

Since that time, the first release of `go.bug.st/relaxed-semver`, offering the opportunity for more effective management
of the dependency:

- Greater stability through the use of release versions
- Automated update offers from Dependabot

The relevant changes made to `go.bug.st/relaxed-semver` in the interim have been the expansion of the version
constraints syntax, so it will be important for Arduino Lint to use the same version as
`arduino/libraries-repository-engine` and Arduino CLI in order to correctly lint the constraints syntax used in the
library.properties `depends` field.
This will allow the code to be shared by additional rule functions which need this data.
… field elements

Empty version constraints are supported by the Arduino library system (they match any version).

Previously, the regular expression used to split the library name from the version constraint caused these empty
constraints to incorrectly be considered invalid.
Arduino CLI and the Library Manager system have support for specifying version constraints in the library.properties
`depends` field.

This was previously validated as part of the general `depends` field data format check in LP047.

The constraint system has recently been made much more capable through the addition of support for more syntax.

The previous approach for validating the version constraint was a complex and lengthy regular expression in the
library.properties JSON schema. Extending this to comprehensively validate the full range of constraint forms possible
with the new syntax will not be feasible or maintainable.

The new approach is to validate it using the same `go.bug.st/relaxed-semver` module used by Arduino CLI and
`arduino/libraries-repository-engine` to handle the version constraints in this field.
@per1234 per1234 added topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project labels May 26, 2022
@per1234 per1234 requested a review from umbynos May 26, 2022 07:06
@per1234 per1234 self-assigned this May 26, 2022
…ibrary.properties schema

A regular expression is employed in the library.properties JSON schemas to validate the format of the contents of the
depends field. Previously, this regular expression was configured to validate the syntax of the optional version
constraint.

The constraint system has recently been made much more capable through the addition of support for more syntax. The
regular expression did not have support for that syntax, which caused valid data to fail validation.

Expanding the already complex and lengthy regular expression to comprehensively validate the full range of constraint
forms possible
with the new syntax would not be feasible or maintainable.

The new approach is to validate it directly via Go code using the same `go.bug.st/relaxed-semver` module used by
Arduino CLI and `arduino/libraries-repository-engine` to handle the version constraints in this field. The schema will
continue to provide a general validation on the `depends` field format.
@codecov-commenter
Copy link

codecov-commenter commented May 26, 2022

Codecov Report

Merging #384 (264f66a) into main (fa3e94c) will increase coverage by 0.04%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main     #384      +/-   ##
==========================================
+ Coverage   90.01%   90.05%   +0.04%     
==========================================
  Files          44       44              
  Lines        6770     6800      +30     
==========================================
+ Hits         6094     6124      +30     
  Misses        553      553              
  Partials      123      123              
Flag Coverage Δ
unit 90.05% <100.00%> (+0.04%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...ternal/rule/ruleconfiguration/ruleconfiguration.go 100.00% <ø> (ø)
internal/rule/schema/schemadata/bindata.go 49.67% <ø> (ø)
internal/rule/rulefunction/library.go 96.39% <100.00%> (+0.10%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update fb7be8a...264f66a. Read the comment docs.

@per1234 per1234 merged commit f05802f into arduino:main May 26, 2022
@per1234 per1234 deleted the full-depends-constraints-support branch May 26, 2022 12:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants